#include "widget.h"
#include"playgame.h"
Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    this->resize(1149,702);
    //窗口
    this->setWindowTitle("Fishing Joy");//窗口名字
    this->setWindowIcon(QIcon(":/1/widgetfish_1.png"));//设置图标（在左上角小图标
    //背景
    QPalette palette;//调色板
    palette.setBrush(QPalette::Background,QBrush(QPixmap(":/1/newbackground.jpg")));//笔刷，添加背景图片
    this->setPalette(palette);

    //初始化标签
   // this->label=new QLabel(this);
    //label->setPixmap(QPixmap("D:/yangkaiwendeqt/homework_1/photos/Fish Joy.jpg"));

    //添加按钮
    this->firstbutton=new QPushButton(this);
    this->firstbutton->setIcon(QIcon(":/1/start121_45.jpg"));
    this->firstbutton->setIconSize(QSize(121,45));
    this->firstbutton->setFlat(true);
    this->setFocusPolicy(Qt::NoFocus);

    this->secondbutton=new QPushButton(this);
    this->secondbutton->setIcon(QIcon(":/1/help121_75.png"));
    this->secondbutton->setIconSize(QSize(121,75));
    this->setFocusPolicy(Qt::NoFocus);
    this->secondbutton->setFlat(true);
    this->setFocusPolicy(Qt::NoFocus);//可以去掉黑虚框


    this->thirdbutton=new QPushButton(this);
    this->thirdbutton->setIcon(QIcon(":/1/quit121_60.png"));
    this->thirdbutton->setIconSize(QSize(121,60));
    this->setFocusPolicy(Qt::NoFocus);
    this->thirdbutton->setFlat(true);
    this->setFocusPolicy(Qt::NoFocus);

    //布局避免堆积在一起，垂直分布     采用坐标使其下移？？
    this->buju=new QVBoxLayout(this);
    this->buju->addWidget(firstbutton);
    this->buju->addWidget(secondbutton);
    this->buju->addWidget(thirdbutton);

    w=new playgame(this);
    w->hide();//防止窗口堆叠

    //主窗口点击跳转第二个窗口
    this->connect(firstbutton,SIGNAL(clicked()),this,SLOT(firstbuttonclick()));
    
    this->connect(thirdbutton,SIGNAL(clicked()),this,SLOT(thirdbuttonclick()));
}

Widget::~Widget()
{
    delete this->firstbutton;
    delete this->secondbutton;
    delete this->thirdbutton;
    delete this->buju;

}
void Widget::firstbuttonclick()
{
    //this->hide();// 隐藏原窗口
    w->show();
}
void Widget::thirdbuttonclick()
{
    if(QMessageBox::Yes==QMessageBox::question(this,"退出提醒qnq","真的不再多玩一会儿了吗QAQ"))
    {
        this->close();
    }
}


